package pwd.allen.behavior.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 门那粒沙
 * @create 2021-05-22 23:11
 **/
public class ListAggregate<T> implements Aggregate<T> {

    private List<T> list = new ArrayList<T>();

    @Override
    public void add(T obj) {
        list.add(obj);
    }

    @Override
    public void remove(T obj) {
        list.remove(obj);
    }

    @Override
    public Iterator getIterator() {
        return new ListIterator(list);
    }
}
